var swap;
var temp;
var count;
do
{
    swap = false;
    for (count = 0; count < (array_length_1d(turnOrder) -1); count++;)
    {
        if (turnOrder[count]).mspeed < (turnOrder[count + 1]).mspeed
        {
            temp = turnOrder[count];
            turnOrder[count] = turnOrder[count+1];
            turnOrder[count+1] = temp;
            swap = true;
        }
    }
}
until (!swap);
